<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 不含连续1的非负整数 -->
    <script>
      var findIntegers = function (n) {
        // 数字0
        let res = 1
        const dfs = val => {
          if (val > n) {
            return
          }
          res++
          if (val & 1) {
            // 1结尾，补0
            dfs(val << 1)
          } else {
            // 0结尾，可补0或1
            dfs(val << 1)
            dfs((val << 1) + 1)
          }
        }
        dfs(1)
        return res
      }
      console.log(findIntegers(5))
    </script>
  </body>
</html>
